<template>
  <div>
    <el-form label-width="80px" label-position="left" :model="searchForm">
      <el-row>
        <el-col :span="8">
          <el-form-item label="所在地区">
            <el-cascader
              v-model="searchForm.area_temp"
              ref="cascader"
              :options="areaOptions"
              :props="defaultProps"
              @change="handleChange(), (searchForm.area_id = areaIds)"
            ></el-cascader>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="学校名称">
            <el-input v-model="searchForm.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建时间">
            <el-date-picker
              v-model="searchForm.createTime"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row>
      <el-col :span="8">
        <el-button @click="onSearch" type="primary">查 询</el-button>
        <el-button @click="reset(), (areaIds = [])">重 置</el-button>
      </el-col>
    </el-row>
    <hr />
    <el-button type="primary" @click="toAdd">新 增</el-button>
    <page-table
      :data="tableData"
      :total="count"
      :page="pageIndex"
      :pageSize="pageSize"
      ref="pageTable"
      showIndex
      @currentChange="currentChange"
      @sizeChange="sizeChange"
      :loading="loading"
    >
      <el-table-column
        prop="name"
        label="学校名"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column label="创建时间">
        <template slot-scope="{ row }">
          {{ row.createdAt | timeFilter }}
        </template>
      </el-table-column>
      <el-table-column prop="areaName" label="所在地区"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <el-button type="text" @click="toRemove(row.id)">删除</el-button>
          <el-button type="text" @click="toEdit(row.id)">修改</el-button>
          <el-button type="text" @click="toDetail(row.id)">详情</el-button>
        </template>
      </el-table-column>
    </page-table>
    <post-dialog @cancel="cancel" :dialogVisible="dialogVisible" :opId="opId" />
    <detail-dialog
      @cancel="cancel1"
      :dialogVisible="dialogVisible1"
      :opId="opId"
    />
  </div>
</template>

<script>
import getAreaList from "../../../mixins/getAreaList";
import initData from "../../../mixins/initData";
import PostDialog from "../components/postDialog";
import DetailDialog from "../components/detailDialog";

export default {
  components: { DetailDialog, PostDialog },
  name: "schoolManage",
  mixins: [getAreaList, initData],
  data() {
    return {
      getUrl: "/api/school/school",
      searchForm: {
        name: "",
        createTime: "",
        area_temp: "",
        area_id: ""
      }
    };
  }
};
</script>

<style scoped></style>
